
clear all

#delimit ;
*  PSID DATA CENTER *****************************************************
   JOBID            : 295634                            
   DATA_DOMAIN      : IND                               
   USER_WHERE       : NULL                              
   FILE_TYPE        : All Individuals Data              
   OUTPUT_DATA_TYPE : ASCII                             
   STATEMENTS       : do                                
   CODEBOOK_TYPE    : PDF                               
   N_OF_VARIABLES   : 53                                
   N_OF_OBSERVATIONS: 38042                             
   MAX_REC_LENGTH   : 137                               
   DATE & TIME      : July 18, 2021 @ 17:31:23
*************************************************************************
;

infix
      ER30000              1 - 1           ER30001              2 - 5           ER30002              6 - 8     
      ER10001              9 - 9           ER12161             10 - 12          ER33401             13 - 17    
      ER33402             18 - 19          ER33403             20 - 21          ER13001             22 - 22    
      ER15898             23 - 25          ER33501             26 - 30          ER33502             31 - 32    
      ER33503             33 - 34          ER17001             35 - 35          ER19959             36 - 38    
      ER33601             39 - 42          ER33602             43 - 44          ER33603             45 - 46    
      ER21001             47 - 47          ER23396             48 - 50          ER33701             51 - 55    
      ER33702             56 - 57          ER33703             58 - 59          ER25001             60 - 60    
      ER27361             61 - 63          ER33801             64 - 68          ER33802             69 - 70    
      ER33803             71 - 72          ER36001             73 - 73          ER40536             74 - 76    
      ER33901             77 - 81          ER33902             82 - 83          ER33903             84 - 85    
      ER42001             86 - 86          ER46513             87 - 89          ER34001             90 - 94    
      ER34002             95 - 96          ER34003             97 - 98          ER47301             99 - 99    
      ER51874            100 - 102         ER34101            103 - 107         ER34102            108 - 109   
      ER34103            110 - 111         ER53001            112 - 112         ER57627            113 - 115   
      ER34201            116 - 120         ER34202            121 - 122         ER34203            123 - 124   
      ER60001            125 - 125         ER64778            126 - 128         ER34301            129 - 133   
      ER34302            134 - 135         ER34303            136 - 137   
using ./RawData/retrospective.txt, clear 
;
label variable ER30000         "RELEASE NUMBER"                           ;
label variable ER30001         "1968 INTERVIEW NUMBER"                    ;
label variable ER30002         "PERSON NUMBER                         68" ;
label variable ER10001         "RELEASE NUMBER"                           ;
label variable ER12161         "L10-10A OCCUPATION OF FATHER"             ;
label variable ER33401         "1997 INTERVIEW NUMBER"                    ;
label variable ER33402         "SEQUENCE NUMBER                       97" ;
label variable ER33403         "RELATION TO HEAD                      97" ;
label variable ER13001         "RELEASE NUMBER"                           ;
label variable ER15898         "L10-10A OCCUPATION OF FATHER"             ;
label variable ER33501         "1999 INTERVIEW NUMBER"                    ;
label variable ER33502         "SEQUENCE NUMBER                       99" ;
label variable ER33503         "RELATION TO HEAD                      99" ;
label variable ER17001         "RELEASE NUMBER"                           ;
label variable ER19959         "L10-10A OCCUPATION OF FATHER"             ;
label variable ER33601         "2001 INTERVIEW NUMBER"                    ;
label variable ER33602         "SEQUENCE NUMBER                       01" ;
label variable ER33603         "RELATION TO HEAD                      01" ;
label variable ER21001         "RELEASE NUMBER"                           ;
label variable ER23396         "L10-10A OCCUPATION OF FATHER"             ;
label variable ER33701         "2003 INTERVIEW NUMBER"                    ;
label variable ER33702         "SEQUENCE NUMBER                       03" ;
label variable ER33703         "RELATION TO HEAD                      03" ;
label variable ER25001         "RELEASE NUMBER"                           ;
label variable ER27361         "L10-10A OCCUPATION OF FATHER-HD"          ;
label variable ER33801         "2005 INTERVIEW NUMBER"                    ;
label variable ER33802         "SEQUENCE NUMBER                       05" ;
label variable ER33803         "RELATION TO HEAD                      05" ;
label variable ER36001         "RELEASE NUMBER"                           ;
label variable ER40536         "L10-10A OCCUPATION OF FATHER-HD"          ;
label variable ER33901         "2007 INTERVIEW NUMBER"                    ;
label variable ER33902         "SEQUENCE NUMBER                       07" ;
label variable ER33903         "RELATION TO HEAD                      07" ;
label variable ER42001         "RELEASE NUMBER"                           ;
label variable ER46513         "L10-10A OCCUPATION OF FATHER-HD"          ;
label variable ER34001         "2009 INTERVIEW NUMBER"                    ;
label variable ER34002         "SEQUENCE NUMBER                       09" ;
label variable ER34003         "RELATION TO HEAD                      09" ;
label variable ER47301         "RELEASE NUMBER"                           ;
label variable ER51874         "L10 OCCUPATION OF FATHER-HD"              ;
label variable ER34101         "2011 INTERVIEW NUMBER"                    ;
label variable ER34102         "SEQUENCE NUMBER                       11" ;
label variable ER34103         "RELATION TO HEAD                      11" ;
label variable ER53001         "RELEASE NUMBER"                           ;
label variable ER57627         "L10 OCCUPATION OF FATHER-HD"              ;
label variable ER34201         "2013 INTERVIEW NUMBER"                    ;
label variable ER34202         "SEQUENCE NUMBER                       13" ;
label variable ER34203         "RELATION TO HEAD                      13" ;
label variable ER60001         "RELEASE NUMBER"                           ;
label variable ER64778         "L10 OCCUPATION OF FATHER-HD"              ;
label variable ER34301         "2015 INTERVIEW NUMBER"                    ;
label variable ER34302         "SEQUENCE NUMBER                       15" ;
label variable ER34303         "RELATION TO HEAD                      15" ;

do ./RawData/retrospective_formats.do ;
#delimit cr

// RETROSPECTIVE FATHER OCC 

	rename ER12161 father_occ_1997
	rename ER15898 father_occ_1999
	rename ER19959 father_occ_2001
	rename ER23396 father_occ_2003
	rename ER27361 father_occ_2005
	rename ER40536 father_occ_2007
	rename ER46513 father_occ_2009
	rename ER51874 father_occ_2011
	rename ER57627 father_occ_2013
	rename ER64778 father_occ_2015

// CREATE SON_ID, KEEP PERTINENT VARS, SAVE
	ren ER30001 famid
	ren ER30002 personnumber

	gen son_id = famid*1000 + personnumber
	label var son_id "Child 1968 ID"
	duplicates report son_id //no duplicates
	
	keep son_id famid personnumber father_occ*
		
	sort son_id 
	compress
	save ./RawData/retrospective_info, replace


